﻿//商品类别
window.operateEvents = {
    'click .glcd': function (e, value, row, index) {
        MyDialog.viewform("Comon/CommonView.aspx?FormCode=SPGL&FormID=" + row.ID, "查看数据")

    },
    'click .tj': function (e, value, row, index) {
        $.post("../SpeList/DLLAjaxHandler.ashx", { Action: "UpdateTJ", ID: row.ID, Status: "Y" },
function (data) {
    if (data == "") {
        $("#FTGrid").bootstrapTable('updateRow', {
            index: index,
            row: {
                ISTJ: 'Y'
            }
        });
        toastr.success("操作成功");
    } else {
        toastr.error("操作失败");
    }
});
    },
    'click .qxtj': function (e, value, row, index) {
        $.post("../SpeList/DLLAjaxHandler.ashx", { Action: "UpdateTJ", ID: row.ID, Status: "N" },
function (data) {
    if (data == "") {
        $("#FTGrid").bootstrapTable('updateRow', {
            index: index,
            row: {
                ISTJ: 'N'
            }
        });
        toastr.success("操作成功");
    } else {
        toastr.error("操作失败");
    }
});
    }
};
var option = {};
option.columns = [
             {
                 field: 'ID',
                 title: '序号'
             }, {
                 sortable: true,
                 field: 'MenuTxt',
                 title: '类别'
             }, {
                 field: 'MenuTxt1',
                 title: '子类别',
             }, {
                 sortable: true,
                 field: 'Title',
                 title: '商品名称'
             }, {
                 field: 'Price1',
                 title: '市场价',
             }, {
                 sortable: true,
                 field: 'Price2',
                 title: '销售价'
             }, {
                 sortable: true,
                 field: 'IsSelf',
                 title: '是否上架',
                 formatter: function (value, row) {
                     return value == "1" ? "上架" : "下架";
                 }
             }, {
                 field: 'ISTJ',
                 title: '是否推荐', formatter: function (value, row, index) {
                     if (row.ISTJ != "Y") {
                         return "<a  class='tj' href='#' dataid='" + row.ID + "' rowindex='" + index + "'>推荐</a>";
                     } else {
                         return "<a  class='qxtj' style='color:red'  href='#' dataid='" + row.ID + "' rowindex='" + index + "'>取消推荐</a>";
                     }
                 },
                 events: operateEvents
             }
             , {
                 field: 'CreaterUser',
                 title: '操作',
                 formatter: function (value, row) {
                     return "<a  class='glcd' href='#'>查看商品</a>";
                 },
                 events: operateEvents
             }
];


